import { cloneDeep } from 'lodash-es'

export default function useCustomState<T extends object>(obj: T) {
  const initState = cloneDeep(obj)
  const state = reactive<T>(obj)

  function reset() {
    for (const key in state) {
      state[key] = initState[key as string]
    }
  }

  return { state, reset }
}
